Những câu hỏi liên quan
Linh Đan
Xem chi tiết
Võ Đức Dũng
17 tháng 9 2021 lúc 21:33

câu 1

Program Nguyen_to;

Var n,i:integer;

Function NT(n:integer):Boolean;

Var ok: Boolean;

i: integer;

Begin ok:=true;

for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;

if n < 2 then NT:=false else NT:=ok;

End;

Begin Write('Nhap n: ');

Readln(n); i:=n;

Repeat i:=i+1;

Until NT(i);

Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);

Readln End.

Bình luận (1)
Võ Đức Dũng
17 tháng 9 2021 lúc 21:39

câu 2

uses crt;

const so: set of char=['0','1','2','3','4','5','6','7','8','9'];

var a:array[1..100] of integer;

st,b:string;

c,l,i,n,j:integer;

s, Max: integer;

begin clrscr;

write('Nhap xau:');

readln(st);

l:=length(st);

i:=1;

n:=0;

repeat if (st[i] in so) then begin b:=''

repeat b:=b+st[i];

inc(i);

until (not(st[i] in so)) or (i>l);

inc(n);

val(b,a[n],c);

end;

inc(i);

until i>l;

Max:=a[1];

for i:=2 to n do If Max<A[i] Then Max:=A[i];

Writeln('Phan tu lon nhat cua mang:', Max);

readln;

end.

Bình luận (0)
hoàng phong Lương
Xem chi tiết
Nguyễn Hoàng Duy
19 tháng 3 2023 lúc 22:45

program TongChuSo;
var
    n, sum: integer;
begin
    write('Nhap n: ');
    readln(n);
    sum := 0;
    while n > 0 do
    begin
        sum := sum + (n mod 10);
        n := n div 10;
    end;
    writeln('Tong cac chu so cua n la: ', sum);
    readln;
end.

 

Bình luận (0)
Quỳnh Hoa
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 10 2021 lúc 23:22

#include <bits/stdc++.h>

using namespace std;

long n,i,dem,t;

int main()

{

cin>>n;

dem=0;

t=0;

for (i=1; i<=n;i++)

if (n%i==0) 

{

dem++;

t=t+i;

}

cout<<dem<<" "<<t;

return 0;

}

Bình luận (0)
Gia Hưng Lớp 7/2
Xem chi tiết
Nguyễn Quốc Đạt
3 tháng 11 2023 lúc 0:38

#include <bits/stdc++.h>

using namespace std;

int main () { int a[1000],n,i;

cin >> n;

for (int i=1;i<=n;i++)

cin >> a[i];

for (int i=2;i<=n;i++)

if (((a[i]<0) and (a[i-1]<0)) or ((a[i]>0) and (a[i-1]>0))) {

cout << a[i-1] <<" " << a[i];

break; }

return 0;

}

Bình luận (0)
Đăng Trần Minh
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 15:09

uses crt;

var n:integer;

begin

clrscr;

readln(n);

writeln(n);

readln;

end.

Bình luận (0)
Hưng Quốc
Xem chi tiết
Thanh Phong (9A5)
31 tháng 3 2023 lúc 16:51

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
láobốlaos
31 tháng 3 2023 lúc 16:54

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
Nguyễn Hoàng Duy
2 tháng 4 2023 lúc 16:31

1.

program InDaySoTuNhien;
var n, i: integer;
begin
   write('Nhap so nguyen duong n: ');
   readln(n);

   writeln('Day so tu 1 den ', n, ' la:');
   for i := 1 to n do
      write(i, ' ');
end.

2.

program InSoChan;
var
   n, i: integer;
begin
   write('Nhap so nguyen n: ');
   readln(n);

   writeln('Cac so nguyen chan trong khoang tu 1 den ', n, ' la:');
   for i := 1 to n do
   begin
      if i mod 2 = 0 then
         write(i, ' ');
   end;
end.

Bình luận (0)
Vân Ngô
Xem chi tiết
Ngô Thành Chung
26 tháng 3 2022 lúc 17:05

var a:Array [1..100] of word;

      n,i:byte;

      S:word;

begin

 write('Nhap so so hang trong day : n = '); readln(n);

 for i:=1 to n do begin

                          write('A[',i,'] = '); 

                          readln(A[i]);

                         end;

S:=0;

for i:=1 to n do if A[i] mod 2 = 1 then S:=S+A[i];

if S = 0 then write('Trong day khong co so le nao nen khong tong khong ton tai') else write('Tong cac so le trong day la : S = ',S);

readln

end.

Bình luận (0)
Dương Quỳnh Chi
Xem chi tiết
KhảTâm
14 tháng 5 2021 lúc 15:55

program tongduong;

uses crt;

var a:array[1..100] of integer;n,i,s:integer;

begin

clrscr;

s:=0;

writeln('nhap do dai cua day');readln(n);

for i:=1 to n do begin writeln('a[',i,']= ');readln(a[i]); end;

for i:=1 to n do if a[i] mod 2 = 0 then s:=s+a[i];

write(' Tong cac so duong trong day la',s);

readln

end.

Bạn the pie mới có lệnh nhập độ dài của dãy còn chưa có lệnh nhập các phần tử trong dãy nhé :)))

Bình luận (0)
 Khách vãng lai đã xóa
︵✿t̾h̾e̾ p̾i̾e̾‿✿
14 tháng 5 2021 lúc 10:20

uses crt;

var a:array[1..249]of integer;

i,n,t,dem:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (0<n) and (n<250);

Bình luận (0)
 Khách vãng lai đã xóa
Dương Nguyễn
12 tháng 3 2023 lúc 9:57

uses crt;

var i,n:integer;

      s:longint;

begin

write('nhap n:');readln(n);

for i:=1 to n do if i mod 2=0 then s:=s+i;

write('tong cac phan tu chan trong day la:',s);

readln;

end.

Bình luận (0)
phamthiminhanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 20:42

Bài 1:

uses crt;

var n,i,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

for i:=1 to n do 

 if i mod 6=0 then s:=s+i;

writeln(s);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 20:46

Bài 2: 

uses crt;

var a,b,c,ucln,i:integer;

begin

clrscr;

write('a='); readln(a);

write('b='); readln(b);

write('c='); readln(c);

while a<>b do 

  begin

if a>b then a:=a-b

else b:=b-a;

end;

ucln:=a;

while ucln<>c do 

 begin

if ucln>c then ucln:=ucln-c

else c:=c-ucln;

end;

writeln(ucln);

readln;

end.

Bình luận (0)
Yoriichi_Tsugikuni ( ɻɛɑ...
11 tháng 6 2021 lúc 14:55

Scratch hay java

Bình luận (0)
 Khách vãng lai đã xóa
phạm hương trà
Xem chi tiết
Công Chúa Sakura
4 tháng 1 2017 lúc 22:32

a)

uses crt;

VAR

n, d, i: integer;

BEGIN

clrscr;

Writeln ('Nhap vao n='); readln (n);

d : = 1;

For i: = 1 to n do

d: = d*i;

Writeln ('d=',d);

Readln;

END.

c)

uses crt;

VAR

n, i, demuoc: integer;

BEGIN

clrscr;

Writeln ('Nhap vao n='); readln (n);

demuoc: = 0;

For i: = 1 to n do

If n mod i = 0 then

demuoc : = demuoc + 1;

If demuoc = 2 then

Writeln ('n la so nguyen to')

ELSE

Writeln ('n khong phai la so nguyen to');

Readln ;

END.

Còn phần b bạn tự nghĩ nha!

Chúc bạn học tốt!

Bình luận (0)